package zb.wzby;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author wzby
 * @Date: 2022/8/9 20:44
 */
public class VolatileText {
    int count = 0;
    synchronized void zb(){
        for ( int i = 0;i < 100; i++) count++;
    }

    public static void main(String[] args) {
        var vt = new VolatileText();
        List<Thread> lt = new ArrayList<>();
        for (int i = 0; i < 10;i++){
            lt.add(new Thread(vt::zb,"what"+i));
        }
        lt.forEach((o) -> o.start());
        lt.forEach((o) -> {
            try {
                o.join();
            }catch (InterruptedException e){
                e.printStackTrace();
            }
        });
        System.out.println(vt.count);
    }
}
